<?php
!function_exists('adminmsg') && exit('Forbidden');
include_once 'mode/house/require/core.php';
$housefieldsService = House::LoadService('HouseFieldsService');
$housefieldsService->updateFieldsCache();
$config = array(
  "house_newhouseifopen"=>1,
  "house_secondhouseifopen"=>1,
  "house_defaultindex"=>0,
  "house_mapcity"=>"请选择",
  "house_mapkey"=>"",
  "house_mapsearch"=>"5",
  "house_evaluation_open"=>"1",
  "house_evaluation_check"=>"1",
  "house_hire_expried"=>30,
  "house_sale_expried"=>60,
  "house_topifopen"=>"1",
  "house_sale_topprice"=>"500",
  "house_sale_topcredit"=>"money",
  "house_sale_num"=>"3",
  "house_hire_topprice"=>"500",
  "house_hire_topcredit"=>"money",
  "house_hire_num"=>"3",
  "house_rapidifopen"=>"1",
  "house_sale_rapidprice"=>"500",
  "house_sale_rapidcredit"=>"money",
  "house_hire_rapidprice"=>"500",
  "house_hire_rapidcredit"=>"money",
  "house_permit"=>"1. 发布信息须符合国家有关法律规定。<br />2. 你须对发布的信息负全部责任。", 
  "house_topprice"=>0,
  "house_rapidprice"=>0,
);
foreach ($config as $key => $value) {
		setConfig($key, $value, null, true);
}
$_sql = " SELECT gid FROM pw_permission WHERE TYPE = 'basic' GROUP BY gid";
$basedb = new BaseDB();
$query  = $basedb->_db->query($_sql);
$basic = $basedb->_getAllResultFromQuery($query,'gid');
$strsql="";
foreach($basic as $key=>$v){
	 $strsql && $strsql.=",";
	 $strsql .= "('0','0','".$key."','house_ifsale','basic','1'),('0','0','".$key."','house_salenum','basic','3'),('0','0','".$key."','house_ifhire','basic','1'),('0','0','".$key."','house_hirenum','basic','3')";
	 
}
$_sql = " SELECT gid FROM pw_permission WHERE TYPE = 'system' GROUP BY gid";
$query  = $basedb->_db->query($_sql);
$system = $basedb->_getAllResultFromQuery($query,'gid');
foreach($basic as $key=>$v){
	 $strsql && $strsql.=",";
	 $strsql .= "('0','0','".$key."','house_sale','system','0'),('0','0','".$key."','house_hire','system','0'),('0','0','".$key."','house_ifsale','basic','1'),('0','0','".$key."','house_salenum','basic','0'),('0','0','".$key."','house_ifhire','basic','1'),('0','0','".$key."','house_hirenum','basic','0')";
}
$_SQL = "REPLACE INTO pw_permission (uid,fid,gid,rkey,type,rvalue) VALUES " .$strsql;
$basedb->_db->query($_SQL);
$update = array_merge(array_keys($system), array_keys($basic));
updatecache_g($update);
updatecache_gr();
updatecache_conf('house', true);
echo "<script language=\"javascript\" type=\"text/javascript\" src=\"http://stats.phpwind.com/pwspider.php?m=site&job=products&pd=fangchan&url=" . urlencode($db_bbsurl) . "&dofrom=" . urlencode('install') . "\"></script>";
adminmsg('operate_success');
?>